<template>
    <div class="knowledge-videos-list">
        <div class="knowledge-videos-item" v-for="item in  props.list " :key="item.id" @click="onPreview(item)">
            <div>
                <div class="img_div">
                    <img class="img_css" :src="item.cover_image ||
                        `${_oss_}/images/home/home-swiper-1.jpg?x-oss-process=image/watermark,image_d2F0ZXIvd2F0ZXJtYXJrLnBuZw`
                        " />
                    <div class="img_layout">
                        <img :src="`/img/video-player-icon.png`" alt=" 北京华锐云空间" />
                    </div>
                </div>
                <div class="title_">
                    <div>{{ item.title }}</div>
                    <div>{{ formatDate(item.createtime, "YYYY.MM.DD") }}</div>
                </div>
            </div>
            <div class="review-num">
                <img :src="`${_oss_}images/works/icon-view-white.png`" alt="北京华锐云空间" />
                <span>{{ item.views || 0 }}</span>
            </div>
        </div>
        <!-- <div class="knowledge-videos-item" @click="onPreview(item)" v-for="item in renderList" :key="item.id">
            <div class="knowledge-videos-item__left">
                <div class="knowledge-videos-item__date">
                    <p class="date">
                        {{ formatDate(item.createtime, "DD") }}
                    </p>
                    <p class="year">
                        {{ formatDate(item.createtime, "YYYY.MM") }}
                    </p>
                </div>

                <div class="knowledge-videos-item__line">
                    <div class="bg"></div>
                </div>
            </div>
            <div class="knowledge-videos-item__right">
                <div class="knowledge-videos-item__title">
                    {{ item.title }}
                </div>
                <div class="knowledge-videos-item__desc">
                    {{ item.subtitle }}
                </div>
            </div>

            <img class="cover-image" :src="item.cover_image ||
                `${_oss_}images/home/home-swiper-1.jpg?x-oss-process=image/watermark,image_d2F0ZXIvd2F0ZXJtYXJrLnBuZw`
                " />
        </div> -->
    </div>

    <PageSeeMoreM v-if="props.list.length > pagination.size * pagination.page" @next="pagination.page += 1" />

    <DialogVideoPreviewM ref="videoPreviewRef" />
</template>
<script setup>
import { useContent } from ".";

const {
    videoPreviewRef,
    onPreview,
} = useContent();

const props = defineProps({
    list: {
        type: Array,
        default: () => [],
    },
});

const pagination = reactive({
    size: 10,
    page: 1,
});

const renderList = computed(() => {
    return props.list.slice(0, pagination.page * pagination.size);
});

</script>
<style lang="scss" scoped>
.knowledge-videos-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-around;
    padding: 0 15px 15px;

    .knowledge-videos-item {
        position: relative;
        display: flex;
        width: 90%;
        height: 250px;
        border-radius: 10px;
        box-shadow: 0px 0px 10px 0px rgba(1, 23, 86, 0.1);
        background-color: #fff;
        cursor: pointer;
        text-decoration: none;
        margin-bottom: 20px;

        .img_css {
            width: 100%;
            height: 180px;
            object-fit: cover;
            border-radius: 10px 10px 0px 0px;
        }

        .title_ {
            width: 100%;
            padding: 10px 0px 0px 12px;

            div {
                &:nth-child(1) {
                    font-size: 18px;
                    color: #333;
                }

                &:nth-child(2) {
                    font-size: 14px;
                    color: #999;
                    padding-top: 8px;
                }
            }
        }

        .img_div {
            position: relative;
        }

        .img_layout {
            position: absolute;
            top: 0;
            left: 0;
            height: 180px;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.3);
            opacity: 0;
            transition: all 0.4s linear;
            border-radius: 10px 10px 0px 0px;
            display: flex;
            justify-content: center;
            /* 水平居中 */
            align-items: center;
            /* 垂直居中 */

            &:hover {
                opacity: 1;
            }
        }


        .review-num {
            position: absolute;
            right: 5px;
            top: 5px;
            display: flex;
            align-items: center;
            color: #fff;
            font-size: 12px;
            background-color: rgba(0, 0, 0, 0.5);
            padding: 5px;
            border-radius: 4px;

            img {
                margin-right: 5px;
                width: 14px;
            }
        }


        .cover-image {
            width: 250px;
            height: 100%;
            position: absolute;
            right: 0;
            top: 0;
            object-fit: cover;
            opacity: 0;
            transition: all 0.4s;
        }

        &:hover {
            border-color: #5085fb;

            .knowledge-videos-item__title {
                color: #5085fb;
            }

            .knowledge-videos-item__line {
                .bg {
                    width: 2px;
                    margin-left: -0.5px;
                    height: 100%;
                }
            }

            .cover-image {
                opacity: 1;
            }

            .knowledge-videos-item__date {

                .date,
                .year {
                    color: #5085fb;
                }
            }
        }

        &__left {
            margin-right: 47px;
            width: 70px;
            flex-shrink: 0;
        }

        &__date {
            text-align: center;
            font-family: "DINCond_Regular";

            .date {
                color: #333;
                font-weight: bold;
                line-height: 1;
                font-size: 62px;
                transition: all 0.4s;
            }

            .year {
                font-size: 20px;
                color: #999;
                margin-top: 6px;
                transition: all 0.4s;
            }
        }

        &__line {
            width: 1px;
            height: 50px;
            background-color: #ddd;
            margin: 10px auto 0;

            .bg {
                width: 100%;
                height: 0%;
                background-color: #5085fb;
                transition: height 0.4s linear;
            }
        }

        &__right {
            margin-top: 10px;
        }

        &__title {
            width: 200px;
            height: 45px;
            line-height: 22.5px;
            font-size: 16px;
            color: #111;
            margin-bottom: 10px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        &__desc {
            line-height: 26px;
            color: #666;
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
    }
}
</style>
